package com.eight.paper.admin.domain.model.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 读取试题来源
 */
public enum QuestionSourceEnum {

    DB("0", "数据库"),
    PAPER("1", "试卷"),
    REDIS("2", "内存数据库");

    String code;
    String name;

    QuestionSourceEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }


    private static final Map<String, QuestionSourceEnum> keyMap = new HashMap<>();

    static {
        for (QuestionSourceEnum item : QuestionSourceEnum.values()) {
            keyMap.put(item.getCode(), item);
        }
    }

    public static QuestionSourceEnum fromCode(String code) {
        return keyMap.get(code);
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
